<div class="ticket-factory">
    <div class="nav">
        <div class="nav-li focus">优惠券</div>
    </div>
    <hr />

    <div class="infobox">
        <div class="ticket-factory-new">
            <h4>新增优惠券 <button event-click="{{'$Event.bus.ticket_factory.add_ticket_factory'}}">确定生成</button> </h4>
            <table class="paper-table">
            	<thead>
            		<td style="width:50%">基础信息</td>
            		<td style="width:50%">配置信息</td>
            	</thead>
            	<tr>
            		<td>
                		<android:input bind-input="{{'$Cache.bus.ticket_factory.new.name'}}" value="{{$Cache.bus.ticket_factory.new.name}}" label="优惠券名称"></android:input>
              <div>
                发行张数限制:
                <inputnumber style="width:120px" loop=1 min=0 value="{{$Cache.bus.ticket_factory.new.ticket_list_limit}}" bind-input="{{'$Cache.bus.ticket_factory.new.ticket_list_limit'}}" value-map-0="不限制"></inputnumber>
              </div>
    					<div>领取开始日期：<android:datePicker value="{{#if $Cache.bus.ticket_factory.new.get_ticket_start_time}}{{#Time $Cache.bus.ticket_factory.new.get_ticket_start_time,'YYYY-MM-DD'}}{{#else}}未设置（不限制）{{/if}}" bind-input="{{'$Cache.bus.ticket_factory.new.get_ticket_start_time'}}"></android:datePicker></div>
						<div>领取结束日期：<android:datePicker value="{{#if $Cache.bus.ticket_factory.new.get_ticket_end_time}}{{#Time $Cache.bus.ticket_factory.new.get_ticket_end_time,'YYYY-MM-DD'}}{{#else}}未设置（不限制）{{/if}}" bind-input="{{'$Cache.bus.ticket_factory.new.get_ticket_end_time'}}"></android:datePicker></div>
            		</td>
            		<td>
            			<div>可使用次数:
            				<inputnumber loop=1 min=1 value="{{$Cache.bus.ticket_factory.new.times}}" bind-input="{{'$Cache.bus.ticket_factory.new.times'}}"></inputnumber>
            			</div>
						<div>过期时间：<android:datePicker value="{{#if $Cache.bus.ticket_factory.new.diedline}}{{#Time $Cache.bus.ticket_factory.new.diedline,'YYYY-MM-DD'}}{{#else}}未设置（永不过期）{{/if}}" bind-input="{{'$Cache.bus.ticket_factory.new.diedline'}}"></android:datePicker></div>
            <div>领取限制：
              <android:switch checked="{{$Cache.bus.ticket_factory.new.forbid_user_get}}" bind-input="{{'$Cache.bus.ticket_factory.new.forbid_user_get'}}">
              {{$Cache.bus.ticket_factory.new.forbid_user_get?'禁止用户直接领取':'允许用户直接领取'}}
              </android:switch>
              {{#if $Cache.bus.ticket_factory.new.forbid_user_get}}
                <i>但可通过抽奖、商家发放等方式获得</i>
              {{/if}}
            </div>
						<div>优惠类型：
<android:selectSearch datalist-key="$Top.$Cache.all_express" use-value-as-result="true" value="{{$Cache.bus.ticket_factory.new.type}}" placeholder="请选择优惠券类型" bind-input="{{'$Cache.bus.ticket_factory.new.type'}}">
    {{#each $Top.$Cache.TICKET_FACTORY_TYPE_array}}
    <optionItem value="{{value}}" search-data="{{value+key}}">{{key}}</optionItem>
    {{/each}}
</android:selectSearch>
{{#if $Cache.bus.ticket_factory.new.type==config.TICKET_FACTORY_TYPE.满减}}
	<div>满减配置：
	<android:input bind-input="{{'$Cache.bus.ticket_factory.new.config.full_cash'}}" value="{{$Cache.bus.ticket_factory.new.config.full_cash}}" label="满" description="订单满多少金额"></android:input>
	<android:input bind-input="{{'$Cache.bus.ticket_factory.new.config.cut_cash'}}" value="{{$Cache.bus.ticket_factory.new.config.cut_cash}}" label="减" description="减免多少金额"></android:input>
	</div>
{{/if}}
{{#if $Cache.bus.ticket_factory.new.type==config.TICKET_FACTORY_TYPE.打折}}
	<div>折扣配置：（100元减免{{#Fixed 100*$Cache.bus.ticket_factory.new.config.discount}}元）
	<inputnumber bind-input="{{'$Cache.bus.ticket_factory.new.config.discount'}}" value="{{$Cache.bus.ticket_factory.new.config.discount}}" loop="0.01" min="0" max="1" fixed="4"></inputnumber>
	</div>
{{/if}}
{{#if $Cache.bus.ticket_factory.new.type==config.TICKET_FACTORY_TYPE.现金抵用}}
	<android:input bind-input="{{'$Cache.bus.ticket_factory.new.config.directly_cut_cash'}}" value="{{$Cache.bus.ticket_factory.new.config.directly_cut_cash}}" label="直接抵扣金额"></android:input>
{{/if}}
						</div>
            		</td>
            	</tr>
            </table>
        </div>
        <div class="ticket-factory-list">
            <h4>现有优惠券</h4>
          	<table class="paper-table">
          		<thead>
          			<td>序号</td>
          			<td>名称</td>
          			<td>描述</td>
          			<td>操作</td>
          		</thead>
          		{{#each $Cache.bus.ticket_factory.list}}
          		<tr>
          			<td>{{$Index+1}}</td>
          			<td>{{info.name}}<copybutton value="{{_id}}">复制ID</copybutton></td>
          			<td>{{info.intro}}</td>
          			<td><button event-click="{{'$App.$Event.bus.ticket_factory.remove_ticket_factory'}}">删除</button></td>
          		</tr>
          		{{/each}}
          	</table>
        </div>
    </div>
</div>
<style>
.ticket-factory .ticket-factory-new .paper-table tr td{
  vertical-align: top;
  padding: 8px;
}
</style>